/**
 * 
 */
package com.kandinfo.isbnmanage.controller;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kandinfo.base.common.dto.ResultDto;
import com.kandinfo.base.common.dto.ResultDtoFactory;
import com.kandinfo.base.security.util.RoleConstants;
import com.kandinfo.isbnmanage.dto.IsbnBusinessReqDto;
import com.kandinfo.isbnmanage.service.IsbnBusinessService;


/**
 * 
 * isbn业务
 * 
 * @author qiweiyang
 *
 */
@Controller
@RequestMapping(value = "/business")
public class IsbnBusinessController {
	
	private final static Logger LOG = LoggerFactory.getLogger(IsbnBusinessController.class);
	 
	@Autowired
	private IsbnBusinessService isbnBusinessService;
	
	/**
	 * 可填充信息填充完成
	 * 
	 * @param isbnBusinessReqDto
	 * 				not null isbnInformationId
	 * @return
	 */
	 @RequiresRoles(value=RoleConstants.ISBN_BUY)
    @RequestMapping(value = "/informationFillCando", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto informationFillCando(@RequestBody IsbnBusinessReqDto isbnBusinessReqDto) {
    	try {
			return isbnBusinessService.informationFillCando(isbnBusinessReqDto);
		} catch (Exception e) {
			LOG.error("informationFillCando ERROR!",e);
			return ResultDtoFactory.toNack(e.getMessage());
		}
    }
    
    /**
	 * 已完善信息
	 * 
	 * @param isbnBusinessReqDto
	 * 				not null isbnInformationId
	 * @return
	 */
	@RequiresRoles(value=RoleConstants.ISBN_COMPLETE)
    @RequestMapping(value = "/informationFillComplete", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto informationFillComplete(@RequestBody IsbnBusinessReqDto isbnBusinessReqDto) {
    	try {
			return isbnBusinessService.informationFillComplete(isbnBusinessReqDto);
		} catch (Exception e) {
			LOG.error("informationFillComplete ERROR!",e);
			return ResultDtoFactory.toNack(e.getMessage());
		}
    }
    
    /**
	 * 图片已上传
	 * 
	 * @param isbnBusinessReqDto
	 * 				not null isbnInformationId
	 * @return
	 */
	@RequiresRoles(value=RoleConstants.ISBN_COMPLETE)
    @RequestMapping(value = "/pageFillComplete", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto pageFillComplete(@RequestBody IsbnBusinessReqDto isbnBusinessReqDto) {
    	try {
			return isbnBusinessService.pageFillComplete(isbnBusinessReqDto);
		} catch (Exception e) {
			LOG.error("pageFillComplete ERROR!",e);
			return ResultDtoFactory.toNack(e.getMessage());
		}
    }
    
    /**
	 * 已审核 同步作业本信息
	 * 
	 * @param isbnBusinessReqDto
	 * 				not null isbnInformationId
	 * @return
	 */
	@RequiresRoles(value=RoleConstants.ISBN_PUBLISH)
    @RequestMapping(value = "/judgeComplete", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto judgeComplete(@RequestBody IsbnBusinessReqDto isbnBusinessReqDto) {
    	try {
			return isbnBusinessService.judgeComplete(isbnBusinessReqDto);
		} catch (Exception e) {
			LOG.error("judgeComplete ERROR!",e);
			return ResultDtoFactory.toNack(e.getMessage());
		}
    }
    
    /**
	 * 发布
	 * 
	 * @param isbnBusinessReqDto
	 * 				not null isbnInformationId
	 * @return
	 */
	@RequiresRoles(value=RoleConstants.ISBN_PUBLISH)
    @RequestMapping(value = "/publish", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto publish(@RequestBody IsbnBusinessReqDto isbnBusinessReqDto) {
    	try {
			return isbnBusinessService.publish(isbnBusinessReqDto);
		} catch (Exception e) {
			LOG.error("publish ERROR!",e);
			return ResultDtoFactory.toNack(e.getMessage());
		}
    }
    
    /**
	 * 取消发布
	 * 
	 * @param isbnBusinessReqDto
	 * 				not null isbnInformationId
	 * @return
	 */
	@RequiresRoles(value=RoleConstants.ISBN_PUBLISH)
    @RequestMapping(value = "/unpublish", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto unpublish(@RequestBody IsbnBusinessReqDto isbnBusinessReqDto) {
    	try {
			return isbnBusinessService.unpublish(isbnBusinessReqDto);
		} catch (Exception e) {
			LOG.error("unpublish ERROR!",e);
			return ResultDtoFactory.toNack(e.getMessage());
		}
    }
    
    /**
	 * 废弃
	 * 
	 * @param isbnBusinessReqDto
	 * 				not null isbnInformationId
	 * @return
	 */
	@RequiresRoles(value=RoleConstants.ISBN_PUBLISH)
    @RequestMapping(value = "/drop", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto drop(@RequestBody IsbnBusinessReqDto isbnBusinessReqDto) {
    	try {
			return isbnBusinessService.drop(isbnBusinessReqDto);
		} catch (Exception e) {
			LOG.error("drop ERROR!",e);
			return ResultDtoFactory.toNack(e.getMessage());
		}
    }
	
	/**
	 * 取消废弃
	 * 
	 * @param isbnBusinessReqDto
	 * 				not null isbnInformationId
	 * @return
	 */
	@RequiresRoles(value=RoleConstants.ISBN_PUBLISH)
    @RequestMapping(value = "/undrop", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto undrop(@RequestBody IsbnBusinessReqDto isbnBusinessReqDto) {
    	try {
			return isbnBusinessService.undrop(isbnBusinessReqDto);
		} catch (Exception e) {
			LOG.error("undrop ERROR!",e);
			return ResultDtoFactory.toNack(e.getMessage());
		}
    }
    
    
}
